class Solution {
public:
    int maxSubArray(vector<int>& nums) {
        int number = 0;
        int maxres = nums[0];
        for(auto ch : nums)
        {
            //判断左缀和和左缀和加本身的大小
            number = max(number+ch,ch);
            //最大值
            maxres = max(number,maxres);
        }
        return maxres;
    }
};